package com.jz.community.basecomm.utils;

import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

import com.jz.community.basecomm.base.BaseApplication;

public class VersionUtils {

	public static final boolean DEBUG = true;

	/**
	 * 获取版本名字
	 */
	public static String getVersionName() {
	    try {
	        PackageManager manager = BaseApplication.getAppInstance().getPackageManager();
	        PackageInfo info = manager.getPackageInfo(BaseApplication.getAppInstance().getPackageName(), 0);
	        return  info.versionName;
	    } catch (Exception e) {
	        e.printStackTrace();
	        return "1.0.0";
	    }
	}
	/**
	 * 获取版本号 code
	 */
	public static int getVersionCode() {
		try {
			PackageManager manager = BaseApplication.getAppInstance().getPackageManager();
			PackageInfo info = manager.getPackageInfo(BaseApplication.getAppInstance().getPackageName(), 0);
			return  info.versionCode;
		} catch (Exception e) {
			e.printStackTrace();
			return 1;
		}
	}

	
}
